| 1 | From: Taylor, Jon (STFC,RAL,ISIS) |
|---|
| 2 | Sent: 12 January 2011 09:37 |
|---|
| 3 | To: Draper, Nick (-,RAL,ISIS) |
|---|
| 4 | Subject: correct conversion to |Q| |
|---|
| 5 | |
|---|
| 6 | Follow Up Flag: Follow up |
|---|
| 7 | Flag Status: Flagged |
|---|
| 8 | |
|---|
| 9 | Hi |
|---|
| 10 | I've dug out the matlab routines we use to calculate |Q| as well as Qx,Qy,Qz |
|---|
| 11 | for both direct and indirect geometries |
|---|
| 12 | They are below |
|---|
| 13 | first we calculate Qx,Qy,Qz. |
|---|
| 14 | then calculate modQ |
|---|
| 15 | Thanks |
|---|
| 16 | Jon |
|---|
| 17 | |
|---|
| 18 | function modQ=spe2modQ(data) |
|---|
| 19 | |
|---|
| 20 | Q=spe2sqe(data); |
|---|
| 21 | modQ=sqrt(Q(:,:,1).^2+Q(:,:,2).^2+Q(:,:,3).^2); |
|---|
| 22 | |
|---|
| 23 | function Q=spe2sqe(spe_data) |
|---|
| 24 | |
|---|
| 25 | % function Q=spe2sqe(spe_data) |
|---|
| 26 | % fields required of spe_data: emode, efixed[meV], en(1,ne)[meV], |
|---|
| 27 | det_theta(ndet,1)[rad], |
|---|
| 28 | % det_psi(ndet,1)[rad](not necessary for IRIS) |
|---|
| 29 | % returns : Q(ndet,ne,3)[?^{-1}] |
|---|
| 30 | % emode=1 if efixed=ei (HET and MARI) and emode=2 if efixed=ef (IRIS) |
|---|
| 31 | % transforms data points in the form (detector_angles,energy) -> |
|---|
| 32 | (Qx,Qy,Qz,energy) |
|---|
| 33 | % in the spectrometer frame where x=[1 0 0] along +k_i, [0 1 0] in the horiz |
|---|
| 34 | scattering plane |
|---|
| 35 | % and z=[0 0 1] \perp to the horizontal plane |
|---|
| 36 | % 11-sep-98 modify const E=2.07k^2 to compare results with PHOENIX, exact |
|---|
| 37 | match |
|---|
| 38 | % restore E/k^2=2.072 |
|---|
| 39 | |
|---|
| 40 | if spe_data.emode==1, |
|---|
| 41 | |
|---|
| 42 | % ====================================================================== |
|---|
| 43 | % For direct-geometry spectrometers like HET, MARI |
|---|
| 44 | % efixed = monochromatic incident energy ei(meV) |
|---|
| 45 | % ====================================================================== |
|---|
| 46 | |
|---|
| 47 | ki=sqrt(spe_data.efixed/2.07); % scalar |
|---|
| 48 | kf=sqrt((spe_data.efixed-spe_data.en)/2.07); % line-vector (1,ne) |
|---|
| 49 | Qx=ki*ones(size(spe_data.det_theta,1),size(spe_data.en,2))... |
|---|
| 50 | -cos(spe_data.det_theta)*kf; % matrix (ndet,ne) |
|---|
| 51 | if ~isfield(spe_data,'det_psi'), |
|---|
| 52 | data.det_psi=zeros(size(spe_data.det_theta)); |
|---|
| 53 | disp(['Assume psi=0 for all detectors']); |
|---|
| 54 | end |
|---|
| 55 | Qy=-(sin(spe_data.det_theta).*cos(spe_data.det_psi))*kf; |
|---|
| 56 | Qz=-(sin(spe_data.det_theta).*sin(spe_data.det_psi))*kf; |
|---|
| 57 | Q=cat(3,Qx,Qy,Qz); |
|---|
| 58 | |
|---|
| 59 | elseif spe_data.emode==2, |
|---|
| 60 | |
|---|
| 61 | % ======================================================================== |
|---|
| 62 | % For indirect-geometry spectrometers like IRIS |
|---|
| 63 | % efixed = monochromatic scattered energy (meV) for a white incident |
|---|
| 64 | beam |
|---|
| 65 | % here all detectors are in the horizontal plane with Psi=0 |
|---|
| 66 | % scattering geometry diagram in notebook computing 2, page 2-14 |
|---|
| 67 | % ======================================================================== |
|---|
| 68 | |
|---|
| 69 | ki=sqrt((spe_data.efixed+spe_data.en)/2.07); % line-vector (1,ne) |
|---|
| 70 | kf=sqrt(spe_data.efixed/2.07); % scalar |
|---|
| 71 | Qx=ones(size(spe_data.det_theta))*ki- |
|---|
| 72 | kf*cos(spe_data.det_theta)*ones(size(spe_data.en)); % matrix (ndet,ne) |
|---|
| 73 | Qy=-kf*(sin(spe_data.det_theta))*ones(size(spe_data.en)); % |
|---|
| 74 | (ndet,1)*(1,ne) |
|---|
| 75 | Qz=zeros(size(Qx)); |
|---|
| 76 | Q=cat(3,Qx,Qy,Qz); |
|---|
| 77 | |
|---|
| 78 | else |
|---|
| 79 | disp('Only inelastic direct-geometry (emode=1, HET, MARI)'); |
|---|
| 80 | disp(' or inelastic indirect-geometry (emode=2, IRIS) spectrometer modes |
|---|
| 81 | available.'); |
|---|
| 82 | disp(['emode=' num2str(emode) ' not implemented. Transformation not |
|---|
| 83 | performed']); |
|---|
| 84 | Q=[]; |
|---|
| 85 | return |
|---|
| 86 | end |
|---|
| 87 | |
|---|
| 88 | |
|---|